import { RetryableTrait, SdkError } from "@smithy/types";

export interface MockOptions {
  name?: string;
  httpStatusCode?: number;
  $retryable?: RetryableTrait;
  cause?: Partial<Error>;
}

export const checkForErrorType = (
  isErrorTypeFunc: (error: SdkError) => boolean,
  options: MockOptions,
): boolean => {
  const error = Object.assign(new Error(), {
    name: options.name,
    $metadata: { httpStatusCode: options.httpStatusCode },
    $retryable: options.$retryable,
    cause: options.cause,
  });
  return isErrorTypeFunc(error as SdkError)
};